	var i=1;
 function addUploadButton()
 {
   	i++;
   	if(i<=10)	
   	{
    		document.getElementById('uploadDiv').innerHTML += '大图:<input type="file" name="bigfile'+i+'"  id="bigfile'+i+'" size="10" />'+		                                           ' 小图:<input type="file" name="smallfile'+i+'"  id="smallfile'+i+'" size="10" /><br/>';
    		document.getElementById('upload_num').value =i;
    }	
 }
 function uploudImg(val)
 {
     	var imagesext = document.getElementById('imagesext').value;	
     	if (document.getElementById("share")!=null && document.getElementById("share").checked)	
     	{
     		var class_attr_str = "";		
     		if(document.getElementById("sort1").value!="")
     		{
    			class_attr_str += document.getElementById("sort1").value + "|";			
    			if(document.getElementById("sort2").value!="")
    			{
    				class_attr_str += document.getElementById("sort2").value + "|";				
    				if(document.getElementById("sort3").value!="")
    				{
    					class_attr_str += document.getElementById("sort3").value + "|";
    				}			
    			}				
    		}	  
    		if(class_attr_str=="")
    		{
    			document.getElementById("class_attr").value = document.getElementById("class_attr_bak").value;		
    			}
    			else
    			{
    				document.getElementById("class_attr1").value = class_attr_str;					
    				document.getElementById("class_attr2").value = class_attr_str;			
    				document.getElementById("class_attr").value = class_attr_str;					
    			}			
    			if(document.getElementById("class_attr").value == "")
    			{
    				alert("请选择图片分类！");				
    				document.getElementById("sort1").focus();				
    				return false;		
    			}		 	  		
    			var area_attr_str = "";		
    			if(document.getElementById("province").value!="")
    			{
    				area_attr_str += document.getElementById("province").value+"|";			
    				if(document.getElementById("eparchy_code").value!="")
    				{
    					area_attr_str += document.getElementById("eparchy_code").value+"|";				
    					if(document.getElementById("city_code").value!="")
    					{
    						area_attr_str += document.getElementById("city_code").value+"|";				
    					}			
    				}	
    			}
    			if(area_attr_str=="")
    			{
    				document.getElementById("area_attr").value = document.getElementById("area_attr_bak").value;		
    			}
    			else
    			{
    				document.getElementById("area_attr1").value = area_attr_str;			
    				document.getElementById("area_attr2").value = area_attr_str;		
    			}		  
    			var province = document.getElementById("province").value;	  
    			if(null == province || province == "")	  
    			{
    	  		alert("请选择产地!");			
    	  		document.getElementById("province").focus();	  	
    	  		return false;	  
    	  	}	  
    	  	document.getElementById("cust_name1").value = document.getElementById("cust_name").value;	  
    	  	document.getElementById("cust_name2").value = document.getElementById("cust_name").value;	
    	 }  	
    	 if(val=='0')	
    	 {
          var minF = document.getElementById('minfile').value;		 
          if(minF=='')	    
          {
    	      	 alert('请选择上传的图片文件');	      	 
    	      	 return;	    
    	     }		  
    	     else		  
    	     {
    		    	var bext = minF.substr(minF.lastIndexOf('.')+1).toLowerCase(); 						
    		    	if(imagesext.indexOf(bext)==-1)
    		    	{
    				 		alert('文件类型不允许上传,请上传'+imagesext+' 类型的文件');		      	 
    				 		return;				
    				 	}	  		  
    			 }		  
    			 document.uploadform.submit();   		  	  	
    		}	 	
    		if(val=='1')	
    		{
        	var upload_num  = document.getElementById('upload_num').value;	  
        	for(var i=1;i<=upload_num;i++)	  
        	{
          	var bigF = document.getElementById('bigfile'+i).value;		  
          	var samllF='';          
          	if(document.getElementById('smallfile'+i)!=null)
          	{
            	samllF = document.getElementById('smallfile'+i).value;          	   
            	if(bigF==''&&samllF=='')
            	{
    		      	alert('请选择上传的图片文件');		      	
    		      	return;		      
    		      }          
    		    }
    		    else
    		   	{
              	if(bigF=='')
              	{
    		      		alert('请选择上传的图片文件');		      	
    		      		return;		      
    		      	}          
    		     }          		   
    		     var bext = bigF.substr(bigF.lastIndexOf('.')+1).toLowerCase(); 			
    		     var sext ='';			
    		     if(samllF!='')
    		     {
    						sext=samllF.substr(samllF.lastIndexOf('.')+1).toLowerCase();				
    						if(imagesext.indexOf(bext)==-1||imagesext.indexOf(sext)==-1)
    						{
    				  		alert('文件类型不允许上传,请上传'+imagesext+' 类型的文件');		      	  
    				  		return;				
    				  	}	  			
    				  }
    				  else
    				 {
    						if(imagesext.indexOf(bext)==-1 )
    						{
    				  		alert('文件类型不允许上传,请上传'+imagesext+' 类型的文件');		      	  
    				  		return;				
    				  	}	  			
    				 }
    			}	   
    			document.goodsForm.submit(); 
	  	   }	
	  		 if(val=='a')
	  		 {
    	    	var catname = document.getElementById('catname').value;		
    	    	if(catname=='')		
    	    	{
    		   		alert('请输入属性名称！');		   
    		   		return;		
    		   	}				 		 		 
    		   	var minF = document.getElementById('catfile').value;		  
    		   	if(minF=='')	      
    		   	{
    	      	 alert('请选择上传的图片文件');	      	 
    	      	 return;	      
    	      }		  
    	      else		  
    	      {
    		    	var bext = minF.substr(minF.lastIndexOf('.')+1).toLowerCase(); 					
    		    	if(imagesext.indexOf(bext)==-1)			
    		    	{
    			  		alert('文件类型不允许上传,请上传'+imagesext+' 类型的文件');	      	  
    			  		return;			
    			  	}	  		  
    			  }		  
    			  document.uploadform.submit();   		
    			}	
}
 
 function deleteDX(val){
        var pkid_path='';    var rdata = Math.round(Math.random()* 10000);           var udata ='attach_name='+val+'&rdata='+rdata;         $.ajax({
    		   type: 'POST',		   url: '/program/plugins/upload/uploadImg/AjaxGetDXIdPath.jsp',		   data: udata,		   async:false,				   		   success: function(msg){
    			    document.getElementById('pkid_path').value =msg; 		   }       });            document.DXform.submit();} 
 function checkChange(obj){
    	if(obj.checked){
    		document.getElementById('ischange').value = '1';		document.getElementById('controlWH').style.visibility='visible';	}else{
    		document.getElementById('ischange').value = '0';		document.getElementById('controlWH').style.visibility='hidden';	}}
 function showImage(obj){
    	document.getElementById('one_file_path').src = obj.src; }
 function levelImage(obj){
    	}
 function closeNotTip(){
    	window.opener = null;	window.open('', '_self');	window.close();}
 function setProvince(){
    	Ts_areaInfo.getAreaClassByUpId('000000000000000',function(data){
    		DWRUtil.removeAllOptions('province');		DWRUtil.addOptions('province',{
    '':'请选择'});		DWRUtil.addOptions('province',data);	})}
 function setCitys(prov){
       var provence=prov;	 Ts_areaInfo.getAreaClassByUpId(provence,function(data){
    		DWRUtil.removeAllOptions('eparchy_code');		DWRUtil.addOptions('eparchy_code',{
    '':'请选择'});		DWRUtil.addOptions('eparchy_code',data);	});}
 function setAreas(city_id){
    	Ts_areaInfo.getAreaClassByUpId(city_id,function(data){
    	 	DWRUtil.removeAllOptions('city_code');     	DWRUtil.addOptions('city_code',{
    '':'请选择'});	 	DWRUtil.addOptions('city_code',data);	});}
 function setOneClass(val){
    	Ts_categoryInfo.getCatClassByUpId("000000000000000",val,setSort1);}
 function setSort1(map_data){
    	var factory = $("sort1");	DWRUtil.removeAllOptions("sort1");	DWRUtil.addOptions('sort1',{
    '':'请选择'});	DWRUtil.addOptions("sort1",map_data);}    var type = "12";
 function setSecondClass(val) {
    	var up_class_id = val;  	Ts_categoryInfo.getCatClassByUpId(up_class_id, type, setSort2);}
 function setSort2(map_data) {
    	DWRUtil.removeAllOptions("sort2");	DWRUtil.addOptions("sort2", {
    '':'请选择'});	DWRUtil.addOptions("sort2", map_data);	var item = $("sort2").length;}
 function setTherdClass(val) {
    	var up_class_id = val;	Ts_categoryInfo.getCatClassByUpId(up_class_id, type, setSort3);}
 function setSort3(map_data) {
    	if (map_data != null) {
    		DWRUtil.removeAllOptions("sort3");		DWRUtil.addOptions("sort3", {
    '':'请选择'});		DWRUtil.addOptions("sort3", map_data);	}} 
 function setTypeName1(obj){
    	  var idx = obj.value;		$("class_id3").value="";		$("class_id2").value="";		$("class_id1").value=idx;	}
 function setClassName1(val) {
    	$("name3").innerHTML = '';	$("name2").innerHTML = '';	$("name1").innerHTML = val;	$("name0").innerHTML = '';}
 function setTypeName2(obj){
    	  var idx = obj.value;	  $("class_id3").value="";		$("class_id2").value=idx;		}
 function setClassName2(val) {
    	$("name3").innerHTML = '';	$("name2").innerHTML = " > "+val;} 
 function setTypeName3(obj){
    	  var idx = obj.value;		$("class_id3").value=idx;		}
 function setClassName3(val) {
    	$("name3").innerHTML = " > "+val;}
 function ChangeClassStyle(){
    	document.getElementById("class_attr").value = "";	document.getElementById("flag_code").value = "1";	document.getElementById("classId1").style.display="none";	document.getElementById("classId2").style.display="";}
 function setProvinces(){
    	Ts_areaInfo.getAreaClassByUpId('000000000000000',function(data){
    		DWRUtil.removeAllOptions('provinces');		DWRUtil.addOptions('provinces',{
    '':'请选择'});		DWRUtil.addOptions('provinces',data);	})}
 function setCityss(prov){
       var provence=prov;	 Ts_areaInfo.getAreaClassByUpId(provence,function(data){
    		DWRUtil.removeAllOptions('eparchy_codes');		DWRUtil.addOptions('eparchy_codes',{
    '':'请选择'});		DWRUtil.addOptions('eparchy_codes',data);	});}
 function setAreass(city_id){
    	Ts_areaInfo.getAreaClassByUpId(city_id,function(data){
    	 	DWRUtil.removeAllOptions('city_codes');     	DWRUtil.addOptions('city_codes',{
    '':'请选择'});	 	DWRUtil.addOptions('city_codes',data);	});}
 function setOneClasss(val){
    	Ts_categoryInfo.getCatClassByUpId("000000000000000",val,setSort1s);}
 function setSort1s(map_data){
    	var factory = $("sort1s");	DWRUtil.removeAllOptions("sort1s");	DWRUtil.addOptions('sort1s',{
    '':'请选择'});	DWRUtil.addOptions("sort1s",map_data);}    var type = "12";
 function setSecondClasss(val) {
    	var up_class_id = val;  	Ts_categoryInfo.getCatClassByUpId(up_class_id, type, setSort2s);}
 function setSort2s(map_data) {
    	DWRUtil.removeAllOptions("sort2s");	DWRUtil.addOptions("sort2s", {
    '':'请选择'});	DWRUtil.addOptions("sort2s", map_data);		var item = $("sort2s").length;}
 function setTherdClasss(val) {
    	var up_class_id = val;	Ts_categoryInfo.getCatClassByUpId(up_class_id, type, setSort3s);}
 function setSort3s(map_data) {
    	if (map_data != null) {
    		DWRUtil.removeAllOptions("sort3s");		DWRUtil.addOptions("sort3s", {
    '':'请选择'});		DWRUtil.addOptions("sort3s", map_data);	}} 
 function setTypeName1s(obj){
    	  var idx = obj.value;		$("class_id3s").value="";		$("class_id2s").value="";		$("class_id1s").value=idx;		} 
 function setTypeName2s(obj){
    	  var idx = obj.value;	  $("class_id3s").value="";		$("class_id2s").value=idx;		} 
 function setTypeName3s(obj){
    	  var idx = obj.value;		$("class_id3s").value=idx;		}
 function searchImg(){
     	 			var class_attr_str = "";		if(document.getElementById("sort1s").value!=""){
    			class_attr_str += document.getElementById("sort1s").value + "|";			if(document.getElementById("sort2s").value!=""){
    				class_attr_str += document.getElementById("sort2s").value + "|";				if(document.getElementById("sort3s").value!=""){
    					class_attr_str += document.getElementById("sort3s").value + "|";				}			}				}	  if(class_attr_str==""){
    			document.getElementById("class_attrs").value = document.getElementById("class_attr_baks").value;		}else{
    			 			document.getElementById("class_attrs").value = class_attr_str;					}			 		 	 		var area_attr_str = "";		if(document.getElementById("provinces").value!=""){
    			area_attr_str += document.getElementById("provinces").value+"|";			if(document.getElementById("eparchy_codes").value!=""){
    				area_attr_str += document.getElementById("eparchy_codes").value+"|";				if(document.getElementById("city_codes").value!=""){
    					area_attr_str += document.getElementById("city_codes").value+"|";				}			}		}		if(area_attr_str==""){
    			document.getElementById("area_attrs").value = document.getElementById("area_attr_baks").value;		}else{
    			 			document.getElementById("area_attrs").value = area_attr_str;		}			  document.searchform.submit();	}  
 function doUseImg(attach_id,copytag){
    	if (copytag != "2")	{
    		document.getElementById("copytag").value = copytag;			document.getElementById("attach_id").value = attach_id;		document.imageuserform.submit();	}	else	{
    		window.opener.CKEDITOR.instances.content.insertHtml(attach_id);		alert('图片已经插入光标位置！');	}}